package com.aiyi.education.user.model;

import com.aiyi.education.entity.KsUserDepartmentWithBLOBs;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * @author renyong
 * @email sxgyry@163.com
 * @date
 */
public class SysDepartTreeModel extends KsUserDepartmentWithBLOBs  implements Serializable {

    /** 对应SysDepart中的id字段,前端数据树中的key*/
    private String key;

    /** 对应SysDepart中的id字段,前端数据树中的value*/
    private String value;

    /** 对应depart_name字段,前端数据树中的title*/
    private String title;
    /**
     * 会员部门ID
     */
    @TableId(value = "depart_id", type = IdType.AUTO)
    private Integer departId;

    /**
     * 部门中文名称
     */
    @TableField("depart_ment_name")
    private String departMentName;

    /**
     * 部门英文名称
     */
    @TableField("depart_ment_ename")
    private String departMentEname;

    /**
     * 部门父ID
     */
    @TableField("parent_id")
    private Integer parentId;

    /**
     * 级别
     */
    @TableField("root")
    private Integer root;

    /**
     * 深度
     */
    @TableField("depth")
    private Byte depth;

    /**
     * 排序ID
     */
    @TableField("order_id")
    private Integer orderId;

    /**
     * 父ID集
     */
    @TableField("parent_id_path")
    private String parentIdPath;

    /**
     * 子部门数
     */
    @TableField("child")
    private Integer child;

    /**
     * 上一个部门ID
     */
    @TableField("prev_id")
    private Integer prevId;

    /**
     * 下一个部门ID
     */
    @TableField("next_id")
    private Integer nextId;

    /**
     * 部门英文名称集
     */
    @TableField("class_dir")
    private String classDir;

    /**
     * 创始人
     */
    @TableField("user_name")
    private String userName;

    /**
     * 创建时间
     */
    @TableField("add_date")
    private Date addDate;

    /**
     * 部门图片
     */
    @TableField("photo_url")
    private String photoUrl;
    /**
     * 介绍
     */
    @TableField("intro")
    private String intro;

    /**
     * 权限
     */
    @TableField("admin_purview")
    private String adminPurview;

    private static final long serialVersionUID = -8458972195631738783L;
    /**
     * 是否是叶子节点
     */
    private boolean isLeaf;

    private List<SysDepartTreeModel> children = new ArrayList<>();

    public List<SysDepartTreeModel> getChildren() {
        return children;
    }

    /**
     * 将KsUserDepartmentWithBLOBs对象转换成SysDepartTreeModel对象
     * @param sysDepart
     */
    public SysDepartTreeModel(KsUserDepartmentWithBLOBs sysDepart) {
        this.key = sysDepart.getDepartId().toString();
        this.value = sysDepart.getDepartId().toString();
        this.title = sysDepart.getDepartMentName();
        this.departId= sysDepart.getDepartId();
        this.parentId = sysDepart.getParentId();
        this.departMentName=sysDepart.getDepartMentName();
        this.departMentEname=sysDepart.getDepartMentEname();
        this.userName=sysDepart.getUserName();
        this.addDate=sysDepart.getAddDate();
        this.photoUrl=sysDepart.getPhotoUrl();
        this.classDir=sysDepart.getClassDir();
        this.child=sysDepart.getChild();
        this.parentIdPath=sysDepart.getParentIdPath();
        this.intro=sysDepart.getIntro();
        this.adminPurview=sysDepart.getAdminPurview();

    }

    public void setChildren(List<SysDepartTreeModel> children) {
        if (children==null){
            this.isLeaf=true;
        }
        this.children = children;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Override
    public Integer getDepartId() {
        return departId;
    }

    @Override
    public void setDepartId(Integer departId) {
        this.departId = departId;
    }

    @Override
    public String getDepartMentName() {
        return departMentName;
    }

    @Override
    public void setDepartMentName(String departMentName) {
        this.departMentName = departMentName;
    }

    @Override
    public String getDepartMentEname() {
        return departMentEname;
    }

    @Override
    public void setDepartMentEname(String departMentEname) {
        this.departMentEname = departMentEname;
    }

    @Override
    public Integer getParentId() {
        return parentId;
    }

    @Override
    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }

    @Override
    public Integer getRoot() {
        return root;
    }

    @Override
    public void setRoot(Integer root) {
        this.root = root;
    }

    @Override
    public Byte getDepth() {
        return depth;
    }

    @Override
    public void setDepth(Byte depth) {
        this.depth = depth;
    }

    @Override
    public Integer getOrderId() {
        return orderId;
    }

    @Override
    public void setOrderId(Integer orderId) {
        this.orderId = orderId;
    }

    @Override
    public String getParentIdPath() {
        return parentIdPath;
    }

    @Override
    public void setParentIdPath(String parentIdPath) {
        this.parentIdPath = parentIdPath;
    }

    @Override
    public Integer getChild() {
        return child;
    }

    @Override
    public void setChild(Integer child) {
        this.child = child;
    }

    @Override
    public Integer getPrevId() {
        return prevId;
    }

    @Override
    public void setPrevId(Integer prevId) {
        this.prevId = prevId;
    }

    @Override
    public Integer getNextId() {
        return nextId;
    }

    @Override
    public void setNextId(Integer nextId) {
        this.nextId = nextId;
    }

    @Override
    public String getClassDir() {
        return classDir;
    }

    @Override
    public void setClassDir(String classDir) {
        this.classDir = classDir;
    }

    @Override
    public String getUserName() {
        return userName;
    }

    @Override
    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Override
    public Date getAddDate() {
        return addDate;
    }

    @Override
    public void setAddDate(Date addDate) {
        this.addDate = addDate;
    }

    @Override
    public String getPhotoUrl() {
        return photoUrl;
    }

    @Override
    public void setPhotoUrl(String photoUrl) {
        this.photoUrl = photoUrl;
    }

    @Override
    public String getIntro() {
        return intro;
    }

    @Override
    public void setIntro(String intro) {
        this.intro = intro;
    }

    @Override
    public String getAdminPurview() {
        return adminPurview;
    }

    @Override
    public void setAdminPurview(String adminPurview) {
        this.adminPurview = adminPurview;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public boolean isLeaf() {
        return isLeaf;
    }

    public void setLeaf(boolean leaf) {
        isLeaf = leaf;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        SysDepartTreeModel that = (SysDepartTreeModel) o;
        return isLeaf == that.isLeaf &&
                Objects.equals(key, that.key) &&
                Objects.equals(value, that.value) &&
                Objects.equals(title, that.title) &&
                Objects.equals(departId, that.departId) &&
                Objects.equals(departMentName, that.departMentName) &&
                Objects.equals(departMentEname, that.departMentEname) &&
                Objects.equals(parentId, that.parentId) &&
                Objects.equals(root, that.root) &&
                Objects.equals(depth, that.depth) &&
                Objects.equals(orderId, that.orderId) &&
                Objects.equals(parentIdPath, that.parentIdPath) &&
                Objects.equals(child, that.child) &&
                Objects.equals(prevId, that.prevId) &&
                Objects.equals(nextId, that.nextId) &&
                Objects.equals(classDir, that.classDir) &&
                Objects.equals(userName, that.userName) &&
                Objects.equals(addDate, that.addDate) &&
                Objects.equals(photoUrl, that.photoUrl) &&
                Objects.equals(intro, that.intro) &&
                Objects.equals(adminPurview, that.adminPurview) &&
                Objects.equals(children, that.children);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), key, value, title, departId, departMentName, departMentEname, parentId, root, depth, orderId, parentIdPath, child, prevId, nextId, classDir, userName, addDate, photoUrl, intro, adminPurview, isLeaf, children);
    }
}
